<?php

/**
 * Albireo Kernel
 *
 * @copyright  Copyright (c) 2010 Albireo Solutions
 * @package    Kernel
 */

namespace KernelModule\LogsModule\PhpModule;

use Nette\Object;
use Nette\Environment;
use Nette\IO\SafeStream;

use KernelModule\LogsModule\LogsBluescreenFileException;

/**
 * This class manages loading the red page
 *
 * @author Pavel
 */

class Detail extends Object {

    /**
     * Returns the filename which matches the hash given as param
     *
     * @param string $hash is the string we need in the filename (hash)
     * @return string filename containing the hash
     */
    public function getDebugFile($hash) {
        if ($hash == NULL) {
	    throw new LogsException(_("No hash given.")); // This should never happen
	    return;
	}
        $files = glob(Environment::expand('%logDir%').DIRECTORY_SEPARATOR."exception ????-??-?? ??-??-?? $hash.html");
        if (!empty($files)) {
            return $files[0];
        } else throw new LogsBluescreenFileException(_("No html page found.")); //this happens whether there is no file corresponding the pattern
    }

}